/**
 * 
 */
package com.gametime.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * @author dave
 *
 */
public class DBUtils {
	
	private static DBUtils instance;
	
	private DBUtils()
	{
		
	}
	
	public static DBUtils getInstance()
	{
		if(instance == null)
			instance = new DBUtils();
		return instance;
	}

	public Connection getConnection() throws SQLException 	
	{
		try
		{
			Class.forName("com.mysql.jdbc.Driver");
		}catch(ClassNotFoundException e)
		{
			e.printStackTrace();
		}
		
		Connection conn = DriverManager
				.getConnection("jdbc:mysql://localhost:3306/gametime","root", "admin");
		return conn;
	}

	public static void closeConnection(Connection conn) {
		if(conn != null)
		{
			try{
				conn.close();
			}catch(Exception e)
			{
				e.printStackTrace();
			}
			conn = null;
		}
		
	}
}
